var limsPerson = Gikam.getPageObject({

    getEditListColumns: function () {
        return [{
            checkbox: true
        }, {
            index: true
        }, {
            field: 'personCode',
            title: 'T_LIMS_PERSON.PERSONCODE'
        }, {
            field: 'personName',
            title: 'T_LIMS_PERSON.PERSONNAME',
            type : 'link'
        }, {
            field: 'initials',
            title: 'T_LIMS_PERSON.INITIALS'
        }, {
            field: 'birthday',
            title: 'T_LIMS_PERSON.BIRTHDAY',
            type: 'date',
        }, {
            field: 'gender',
            title: 'T_LIMS_PERSON.GENDER',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'gender'
            }
        }, {
            field: 'nation',
            title: 'T_LIMS_PERSON.NATION',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'nation',
            }
        }, {
            field: 'jobStatus',
            title: 'T_LIMS_PERSON.JOBSTATUS',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'jobStatus',
            },
        }, {
            field: 'education',
            title: 'T_LIMS_PERSON.EDUCATION',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'education',
            },
        }, {
            field: 'schoolName',
            title: 'T_LIMS_PERSON.SCHOOLNAME'
        }, {
            field: 'graduationTime',
            title: 'T_LIMS_PERSON.GRADUATIONTIME',
            type: 'date'
        }, {
            field: 'academicDegree',
            title: 'T_LIMS_PERSON.ACADEMICDEGREE',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'academicDegree',
            },
        }, {
            field: 'entryTime',
            title: 'T_LIMS_PERSON.ENTRYTIME',
            type: 'date'
        }, {
            field: 'terminationTime',
            title: 'T_LIMS_PERSON.TERMINATIONTIME',
            type: 'date'
        }, {
            field: 'profession',
            title: 'T_LIMS_PERSON.PROFESSION'
        }, {
            field: 'mobile',
            title: 'T_LIMS_PERSON.MOBILE'
        }, {
            field: 'email',
            title: 'T_LIMS_PERSON.EMAIL'
        }, {
            field: 'office',
            title: 'T_LIMS_PERSON.OFFICE'
        }, {
            field: 'jobTitle',
            title: 'T_LIMS_PERSON.JOBTITLE'
        }, {
            field: 'contactNumber',
            title: 'T_LIMS_PERSON.CONTACTNUMBER'
        }, {
            field: 'contactAdress',
            title: 'T_LIMS_PERSON.CONTACTADRESS'
        }, {
            field: 'employNumber',
            title: 'T_LIMS_PERSON.EMPLOYNUMBER'
        }, {
            field: 'dept',
            title: 'T_LIMS_PERSON.DEPT'
        }]
    },

    getPersonInsertFormFields: function () {
        return [{
            field: 'personCode',
            title: 'T_LIMS_PERSON.PERSONCODE',
            validators: ['remote[/secure/basemodule/rm/persons/{personCode}action/validate-unique]', 'notEmpty', 'strLength[0,20]'],
            preInsert: true,
            type: 'choose',
            category: 'user',
            single: true,
            onAfterChoose: function (row, index) {
                if (row && row[0]) {
                    this.setData({
                        personCode: row[0].id,
                        personName: row[0].userName,
                        mobile: row[0].mobile,
                        email: row[0].email
                    })
                }
            },
            onBeforeChoose: function () {
                return {
                    target_filter: encodeURI(JSON.stringify({
                        type: 'unassigned',
                        targetTable: 'T_LIMS_PERSON',
                        targetMatchColumn: 'personCode',
                        thisMatchColumn: 'id'
                    })),
                    status_EQ: 'activated',
                }
            },
        }, {
            field: 'personName',
            title: 'T_LIMS_PERSON.PERSONNAME',
            preInsert: true,
            editable: false,
            readonly: true
        }, {
            field: 'initials',
            title: 'T_LIMS_PERSON.INITIALS',
            validators: ['strLength[0,30]'],
            preInsert: true,
        },]
    },

    getBaseInfoFormFields: function () {
        return [{
            field: 'personCode',
            title: 'T_LIMS_PERSON.PERSONCODE',
            readonly: true
        }, {
            field: 'personName',
            title: 'T_LIMS_PERSON.PERSONNAME',
            readonly: true
        }, {
            field: 'initials',
            title: 'T_LIMS_PERSON.INITIALS',
            validators: ['strLength[0,30]'],
        }, {
            field: 'birthday',
            title: 'T_LIMS_PERSON.BIRTHDAY',
            type: 'date',
            preInsert: true,
            onChange: function (field, value, index) {
                var birthday_time = value.split("-")
                var birthYear = birthday_time[0]
                var d = new Date()
                var nowYear = d.getFullYear()
                var age = nowYear - birthYear
                this.setData({
                    age: age,
                    birthday: value
                })
            },
        }, {
            field: 'gender',
            title: 'T_LIMS_PERSON.GENDER',
            type: 'select',
            firstBlank: false,
            category: 'sys',
            param: {
                codeCategoryId: 'gender'
            }
        }, {
            field: 'nation',
            title: 'T_LIMS_PERSON.NATION',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'nation',
            },
            search: true,
        }, {
            field: 'jobStatus',
            title: 'T_LIMS_PERSON.JOBSTATUS',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'jobStatus',
            },
        }, {
            field: 'education',
            title: 'T_LIMS_PERSON.EDUCATION',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'education',
            },
        }, {
            field: 'schoolName',
            title: 'T_LIMS_PERSON.SCHOOLNAME',
            validators: ['strLength[0,100]'],
        }, {
            field: 'graduationTime',
            title: 'T_LIMS_PERSON.GRADUATIONTIME',
            type: 'date',
            preInsert: true
        }, {
            field: 'academicDegree',
            title: 'T_LIMS_PERSON.ACADEMICDEGREE',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'academicDegree',
            },
        }, {
            field: 'entryTime',
            title: 'T_LIMS_PERSON.ENTRYTIME',
            type: 'date',
            preInsert: true
        }, {
            field: 'terminationTime',
            title: 'T_LIMS_PERSON.TERMINATIONTIME',
            type: 'date',
            preInsert: true
        }, {
            field: 'profession',
            title: 'T_LIMS_PERSON.PROFESSION',
            validators: ['strLength[0,40]'],
        }, {
            field: 'mobile',
            title: 'T_LIMS_PERSON.MOBILE',
            validators: ['phone']
        }, {
            field: 'email',
            title: 'T_LIMS_PERSON.EMAIL',
            validators: ['email', 'strLength[0,50]'],
        }, {
            field: 'office',
            title: 'T_LIMS_PERSON.OFFICE',
            validators: ['strLength[0,50]'],
        }, {
            field: 'jobTitle',
            title: 'T_LIMS_PERSON.JOBTITLE',
            validators: ['strLength[0,20]'],
        }, {
            field: 'contactNumber',
            title: 'T_LIMS_PERSON.CONTACTNUMBER',
            validators: ['strLength[0,50]'],
        }, {
            field: 'contactAdress',
            title: 'T_LIMS_PERSON.CONTACTADRESS',
            validators: ['strLength[0,100]'],
        }, {
            field: 'employNumber',
            title: 'T_LIMS_PERSON.EMPLOYNUMBER',
            validators: ['strLength[0,50]'],
        }, {
            field: 'dept',
            title: 'T_LIMS_PERSON.DEPT',
            validators: ['strLength[0,50]'],
        },]
    },

    getChooseListColumns: function () {
        return [{index: true},{
            field: 'personCode',
            title: 'T_LIMS_PERSON.PERSONCODE'
        }, {
            field: 'personName',
            title: 'T_LIMS_PERSON.PERSONNAME'
        }, {
            field: 'initials',
            title: 'T_LIMS_PERSON.INITIALS'
        },  {
            field: 'gender',
            title: 'T_LIMS_PERSON.GENDER',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'gender'
            }
        }, {
            field: 'nation',
            title: 'T_LIMS_PERSON.NATION',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'nation',
            }
        }, {
            field: 'jobStatus',
            title: 'T_LIMS_PERSON.JOBSTATUS',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'jobStatus',
            },
        }, {
            field: 'education',
            title: 'T_LIMS_PERSON.EDUCATION',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'education',
            },
        }, {
            field: 'schoolName',
            title: 'T_LIMS_PERSON.SCHOOLNAME'
        }, {
            field: 'graduationTime',
            title: 'T_LIMS_PERSON.GRADUATIONTIME',
            type: 'date'
        }, {
            field: 'academicDegree',
            title: 'T_LIMS_PERSON.ACADEMICDEGREE',
            type: 'select',
            category: 'sys',
            param: {
                codeCategoryId: 'academicDegree',
            },
        },{
            field: 'profession',
            title: 'T_LIMS_PERSON.PROFESSION'
        }, {
            field: 'mobile',
            title: 'T_LIMS_PERSON.MOBILE'
        }, {
            field: 'email',
            title: 'T_LIMS_PERSON.EMAIL'
        }, {
            field: 'office',
            title: 'T_LIMS_PERSON.OFFICE'
        }, {
            field: 'jobTitle',
            title: 'T_LIMS_PERSON.JOBTITLE'
        }, {
            field: 'contactNumber',
            title: 'T_LIMS_PERSON.CONTACTNUMBER'
        }, {
            field: 'contactAdress',
            title: 'T_LIMS_PERSON.CONTACTADRESS'
        }, {
            field: 'employNumber',
            title: 'T_LIMS_PERSON.EMPLOYNUMBER'
        }, {
            field: 'dept',
            title: 'T_LIMS_PERSON.DEPT'
        },]
    },

    baseUrl: IFM_CONTEXT + '/secure/basemodule/rm/persons'
})
